int sumOfTheDigitsOfHarshadNumber(int x)
{
    int sum = 0;
    for (int temp = x; temp; temp /= 10)
        sum += temp % 10;
    return x % sum ? -1 : sum;
}